# sprite = codesters.Rectangle(x, y, width, height, "color")
start = codesters.Rectangle(0, -250, 500, 50, "red")
# sprite = codesters.Rectangle(x, y, width, height, "color")
finish = codesters.Rectangle(0, 250, 500, 50, "green")
my_list = [-150, -50, 50, 150]
for value in my_list:
pass # delete after adding indented code
# add code here
# sprite = codesters.Rectangle(x, y, width, height, "color")
sprite = codesters.Rectangle(0, value, 500, 50, "gray")
# sprite = codesters.Sprite("image", x, y)
sprite = codesters.Sprite("turtle1", 0, -240)
sprite.set_size(.2)
sprite.turn_left(90)
def interval():
my_var = random.choice(my_list)
if my_var == -150 or my_var == 50:
pass # delete after adding indented code
# add your code here
sprite = codesters.Sprite("car1")
stage.event_interval(interval, 0.5)
t = codesters.Teacher()
sprites = t.find_function("Sprite")
turn_rights = t.find_function("turn_right")
set_sizes = t.find_function("set_size")
set_x_speeds = t.find_function("set_x_speed")
try:
tval1 = sprites[1][1].lower().replace(' ','')
except:
tval1 = "DNE"
try:
tval2 = turn_rights[0][1].lower().replace(' ','')
tval2_indent = t.get_indent_at_line(turn_rights[0][0])
except:
tval2 = "DNE"
tval2_indent = "DNE"
try:
tval3 = set_sizes[1][1].lower().replace(' ','')
tval3_indent = t.get_indent_at_line(set_sizes[1][0])
except:
tval3 = "DNE"
tval3_indent = "DNE"
try:
tval4 = set_x_speeds[0][1].lower().replace(' ','')
tval4_indent = t.get_indent_at_line(set_x_speeds[0][0])
except:
tval4 = "DNE"
tval4 = "DNE"
t1 = TestObjective()
t1.add_success('("car1",-400,my_var)' in tval1, "Great Job!")
t1.add_failure(tval1 == "DNE", "Oops, did you delete the Car 1 sprite?")
t1.add_failure(tval1 != "DNE" and '("car1",-400,my_var)' not in tval1, "Did you change the arguments for the Car 1 sprite?")
t2 = TestObjective()
t2.add_success(tval2 != "DNE" and tval2_indent == 8, "Great job!")
t2.add_failure(tval2 == "DNE", "Did you add Turn Right inside the if statement?")
t2.add_failure(tval2 != "DNE" and tval2_indent != 8, "Make sure Turn Right is indented two times! Once for the event, once for the if statement.")
t3 = TestObjective()
t3.add_success(tval3 != "DNE" and tval3_indent == 8, "Great job!")
t3.add_failure(tval3 == "DNE", "Did you add Set Size inside the if statement?")
t3.add_failure(tval3 != "DNE" and tval3_indent != 8, "Make sure Set Size is indented two times! Once for the event, once for the if statement.")
t4 = TestObjective()
t4.add_success('sprite.set_x_speed(2)' in tval4 and tval4_indent == 8, "Great job!")
t4.add_failure(tval4 == "DNE", "Did you add Set x Speed inside the if statement?")
t4.add_failure(tval4 != "DNE" and 'sprite.set_x_speed(2)' not in tval4, "Did you change the number in .set_x_speed() from 5 to 2?")
t4.add_failure(tval4 != "DNE" and tval4_indent != 8, "Make sure Set x Speed is indented two times! Once for the event, once for the if statement.")
tester = TestManager()
tester.add_test_list([t1, t2, t3, t4])
tester.run_tests()
tester.display_first_feedback()